package yto.freemarker.springcloud.controller;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import yto.freemarker.springcloud.entity.User;
import yto.freemarker.springcloud.mapper.UserMapper;

/**
 * @author dongxing
 * @create 2018-02-27 22:16
 **/
@RestController
@AllArgsConstructor(onConstructor = @_(@Autowired))
@Slf4j
public class UserController {

    private final UserMapper userMapper;


    @GetMapping("/user/{id}")
    public User findById(@PathVariable Integer id) {
        log.info("通过id查询用户的方法开始执行,id为：{}", id);
        User user = userMapper.selectByPrimaryKey(id);
        return user;

    }
}
